package com.ruoyi.userinfo.contorller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ruoyi
 */
@RestController
@RequestMapping("/user")
public class UserCancelAccount extends BaseController {

    @Autowired
    private ISysUserService userService;

    /**
     * 注销账号
     */

    @DeleteMapping("/cancelAccount")
    public AjaxResult cancelAccount(){

        //获取当前用户id
        LoginUser loginUser = getLoginUser();
        SysUser currentUser = loginUser.getUser();
        long userId = currentUser.getUserId();



        //实际是修改del_flag标志位
        return toAjax(userService.deleteUserById(userId));

    }

}
